package com.lagou.demo.controller;

import com.lagou.demo.service.IDemoService;
import com.lagou.edu.mvcframework.annotations.LagouAutowired;
import com.lagou.edu.mvcframework.annotations.LagouController;
import com.lagou.edu.mvcframework.annotations.LagouRequestMapping;
import com.lagou.edu.mvcframework.annotations.LagouSecurity;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@LagouController
@LagouRequestMapping("/demo")
public class DemoController {


    @LagouAutowired
    private IDemoService demoService;

    /**
     * URL: /demo/query?name=lisi
     * @param request
     * @param response
     * @param name
     * @return
     */
    @LagouRequestMapping("/open")
    public String open(HttpServletRequest request, HttpServletResponse response,String name) {
        return demoService.get(name);

    }

        /**
         * URL: /demo/query?name=lisi
         * @param request
         * @param response
         * @param name
         * @return
         */
    @LagouRequestMapping("/query")
    @LagouSecurity("lisi")
    public String query(HttpServletRequest request, HttpServletResponse response,String name) {
        return demoService.get(name);
    }


    /**
     * URL: /demo/query?name=lisi
     * @param request
     * @param response
     * @param name
     * @return
     */
    @LagouRequestMapping("/add")
    @LagouSecurity("zhangsan")
    public String add(HttpServletRequest request, HttpServletResponse response,String name) {
        return demoService.get(name);
    }
}
